package edu.liuzihao.controller;

import com.alibaba.fastjson.JSON;
import edu.liuzihao.pojo.GenderOfPerson;
import edu.liuzihao.pojo.R;
import edu.liuzihao.pojo.ResData;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Liu
 * @date 2022/12/9 9:22
 **/
@RestController
@RequestMapping("/spark1")
public class GradeController {

    @GetMapping("/Grade")
    public R getJudge() {
        System.out.println("这里是getAllPeople接口");
        List<GenderOfPerson> result = new ArrayList<>();
        if (ResData.AllPeopleList != null) {
            for (String s : ResData.AllPeopleList) {
                try {
                    GenderOfPerson genderOfPerson = JSON.parseObject(s, GenderOfPerson.class);
                    result.add(genderOfPerson);
                } catch (Exception e) {
                }
            }
            ResData.AllPeopleList.clear();
        }
        return R.ok().put("result", result);
    }
}
